package com.lawyer.uitls;

import java.util.Random;
import java.util.regex.Pattern;

public  class BaseUtils {

	/**
	 * 
	 * @param phone
	 * @return 返回true = 是手机号，false = 不是手机号
	 */
	public static boolean checkPhone(String phone) {
		String REGEX_MOBILE = "^1(3\\d{2}|4[14-9]\\d|5([0-35689]\\d|7[1-79])|66\\d|7[2-35-8]\\d|8\\d{2}|9[13589]\\d)\\d{7}$";
		return Pattern.matches(REGEX_MOBILE, phone);
	}

	public static String genRandomCode() {
		int maxNum = 36;
		int i;
		int count = 0;
		char[] str = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4',
				'5', '6', '7', '8', '9' };
		StringBuffer pwd = new StringBuffer("");
		Random r = new Random();
		while (count < 8) {
			i = Math.abs(r.nextInt(maxNum));
			if (i >= 0 && i < str.length) {
				pwd.append(str[i]);
				count++;
			}
		}
		return pwd.toString();
	}

}
